package com.dunqi.gpm.cangxi.home.adapter;

import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseViewHolder;
import com.dunqi.gpm.cangxi.R;
import com.dunqi.gpm.cangxi.common.base.RecyclerAdapter;
import com.dunqi.gpm.cangxi.home.bean.ProjectWorkTrend;
import com.dunqi.gpm.cangxi.home.constance.Constance;
import com.dunqi.gpm.cangxi.home.fragment.HomeFragment;
import com.dunqi.gpm.cangxi.home.widget.NormalView;
import com.dunqi.gpm.cangxi.mine.util.UserUtil;

import java.util.List;

/**
 * Created by Administrator on 2017/12/4.
 */
public class ProjectWorkTrendAdapter extends RecyclerAdapter<ProjectWorkTrend> {

    private final String[] status;

    public ProjectWorkTrendAdapter(@Nullable List<ProjectWorkTrend> data) {
        super(R.layout.item_project_work_trend, data);
        status = Constance.STATUS;
    }

    @Override
    protected void convert(BaseViewHolder helper, ProjectWorkTrend item) {
        int homeMenuId = HomeFragment.homeMenuId;
        NormalView projectName = helper.getView(R.id.project_name_view);
        if (Constance.WORK_TREND_TYPE_PROJEC_TREND.equalsIgnoreCase(item.getTrendType())) {
            projectName.setText(item.getProjectName());
            projectName.setVisibility(View.VISIBLE);
            projectName.setAllViewAsSecondStyle();
            projectName.setAllViewTextSize(12);
        }else
            projectName.setVisibility(View.GONE);

        NormalView titleView = helper.getView(R.id.title_view);
        titleView.setDes("("+item.getTrendTypeText()+")");
        titleView.setText(item.getTrendTitile());
        titleView.setDesWidthMatchContent();
        titleView.setAllViewAsMasterStyle();

        NormalView publicTimeView = helper.getView(R.id.public_time_view);
        publicTimeView.setText(item.getIssueTime());
        publicTimeView.setAllViewAsSecondStyle();
        publicTimeView.setAllViewTextSize(12);


        NormalView auditTypeView = helper.getView(R.id.audit_type_view);
        if (UserUtil.userIsLeader()) {
            auditTypeView.setVisibility(View.GONE);
        }else{

            int auditStatus = item.getAuditStatus();
            auditTypeView.setText(status[auditStatus]);
            auditTypeView.setAllViewAsSecondStyle();
            auditTypeView.setAllViewTextSize(12);
        }


        /*
        int levelType = UserUtil.getLevelType();



        helper.setText(R.id.more_tv, "");


        if (homeMenuId == 13) {
            helper.getView(R.id.more_tv).setVisibility(View.GONE);
            return;
        }

        if (UserUtil.userFromNdrcOrg() && homeMenuId == 17) {
            helper.setText(R.id.more_tv, "审核");
        }
        if ((auditStatus == 3 || auditStatus == 0) && homeMenuId == 13 && UserUtil.userFromRespOrg()) {
            helper.setText(R.id.more_tv, "编辑");
        }
        */

    }
}
